package com.scalar.forecast.columnDisplay.actions;

import com.scalar.forecast.ForecastExtendedAction;
import com.scalar.forecast.commons.SessionKeys;
import com.scalar.forecast.columnDisplay.actionCommands.SearchMetaDataActionCommandFactory;
import com.scalar.forecast.actionCommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 *  Action Class for processing the requests came from Edit Column Display Screen
 *
 * Created by Veeru. 
 * Date: Feb 16, 2005
 * Time: 10:58:00 AM 
 */

public class SearchMetaDataAction extends ForecastExtendedAction {

    public ActionForward executeRequest( ActionMapping mapping,
                                         ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response ) throws Exception{

        ActionForward actionForward = mapping.findForward("");
        String action    = request.getParameter("action");
        HashMap errors = new HashMap ();
        request.setAttribute( SessionKeys.ERROR_MESSAGES, errors );

        try {

            ActionCommand actionCommand = SearchMetaDataActionCommandFactory.getActionCommand( action );
            actionForward = actionCommand.execute( mapping, form, request, response );

        } catch( Exception e){
            errors.put("Error while processing the Search Meta Data Action", null);
        }

        return actionForward ;
    }
}
